#pragma once

#include "device.h"
#include "Texture.h"

#include <d3dx10.h>

#include <string>

namespace Crows3D
{
   struct MatrixBuffer
	{
		D3DXMATRIX world;
		D3DXMATRIX view;
		D3DXMATRIX proj;
	};

   struct LightBuffer
   {
      D3DXVECTOR4 diffuseColor;
      D3DXVECTOR4 ambientColor;
      D3DXVECTOR3 diffuseDirection;
      float       padding;
   };


   class Effect
   {
   protected:

   public:
      Effect(void){}
      ~Effect(void){}

      virtual bool Initialize(Device *dev, std::wstring vsFile, std::wstring psFile){return true;}
      virtual void Commit(Device * dev, Texture * texture, D3DXMATRIX world, D3DXMATRIX view, D3DXMATRIX proj){}
   };


   class EffectPositionTextureNormal : Effect
   {
   protected:
      ID3D11VertexShader *pVS;          // the vertex shader
      ID3D11PixelShader  *pPS;          // the pixel shader
      ID3D11InputLayout  *pLayout;      // input layout object

      ID3D11SamplerState *samplerState; // the texture sampler descriptor


      ID3D11Buffer       *mb;           // Matrix buffer

      ID3D11Buffer       *lb;           // light buffer


   public:
      EffectPositionTextureNormal(void);
      ~EffectPositionTextureNormal(void);

      bool Initialize(Device *dev, std::wstring vsFile, std::wstring psFile);

      bool LoadDefaults(Device *dev);

      void Commit(Device * dev, Texture * texture, D3DXMATRIX world, D3DXMATRIX view, D3DXMATRIX proj);
   };


   class EffectPosition2DTexture : Effect
   {
   protected:
      ID3D11VertexShader *pVS;          // the vertex shader
      ID3D11PixelShader  *pPS;          // the pixel shader
      ID3D11InputLayout  *pLayout;      // input layout object

      ID3D11SamplerState *samplerState; // the texture sampler descriptor

      ID3D11Buffer       *mb;           // Matrix buffer

   public:
      EffectPosition2DTexture(void);
      ~EffectPosition2DTexture(void);

      bool Initialize(Device *dev, std::wstring vsFile, std::wstring psFile);

      bool LoadDefaults(Device *dev);

      void Commit(Device * dev, Texture * texture, D3DXMATRIX world, D3DXMATRIX view, D3DXMATRIX proj);
   };
}